<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <include file="Public:header" />
  <script type="text/javascript" src="__PUBLIC__/jedate/jedate.js"></script>
</head>
<body>
  <include file="Public:body_top" />

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar hidden-xs">
        <div class="menu">
          <dl>
            <dt><i class="cm-order"></i>订单管理</dt>
            <dd><a href="{:U('Orders/index')}">订单列表</a></dd>
            <dd><a href="{:U('Orders/order_count')}">订单统计</a></dd>
            <dd><a href="{:U('Settlements/amount_logs')}">结算记录</a></dd>
          </dl>
        </div>
      </div>
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="main-hd">
          <h5>订单列表</h5>
        </div>
        <div class="main-bd">

          <form method="post" action="{:U('Settlements/index')}" id="myfrom">
            <div class="form-box order-datatime">
              <div class="form-horizontal">

                <div class="form-group">
                  <label class="col-sm-2 control-label">下单时间</label>
                  <div class="col-sm-3">
                    <input class="form-control" type="text" placeholder="开始时间" name="beg_time" value="{$beg_time}" id="beg_time" readonly>
                    <!-- <span class="input-group-addon"><i class="cm-calendar"></i></span> -->
                  </div>
                  <label class="col-sm-1 control-label">到</label>
                  <div class="col-sm-3">
                    <input class="form-control" type="text" placeholder="结束时间" name="end_time" value="{$end_time}" id="end_time" readonly>
                    <!-- <span class="input-group-addon"><i class="cm-calendar"></i></span> -->
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">店铺名称</label>
                  <div class="col-sm-3">
                    <input class="form-control" name="shop_name" type="text" placeholder="输入店铺名称" value="{$shop_name}">
                  </div>
                </div>
                <div class="form-group">
                  <div class="col-sm-12 col-md-9 form-box-btns">
                    <a class="btn btn-primary" href="#" onClick="$('#myfrom').submit()">查询</a>
                    <!--<a class="btn btn-default" href="#">导出</a>-->
                    <a href="{:U('Settlements/do_statistics')}" class="btn btn-default">点击结算</a>
                    <a href="{:U('Settlements/finish')}" class="btn btn-default">完成订单(近10日)</a>
                  </div>
                </div>
              </div>
            </div>
          </form>
          <ul class="nav nav-tabs">
            <li class="active"><a href="#all-order" data-toggle="tab">全部记录</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active" id="all-order">
              <div class="table-responsive">
                <table class="table table-cmcm">
                  <tr>
                    <!--<th>
                        <div class="checkbox">
                          <label><input type="checkbox" class="checkall">全选</label>
                        </div>
                      </th>-->
                    <th>店铺</th>
                    <th>结算金额</th>
                    <th>结算日期</th>
                    <th>结算时间</th>
                    <th>打款状态</th>
                    <th>操作</th>
                  </tr>

                  <volist name="page_list.list" id="vo">
                    <tr>
                      <!-- <td>
                        <div class="checkbox">
                          <label><input type="checkbox"></label>
                        </div>
                      </td>-->
                      <td>{$vo.shop_name}</td>
                      <td>{$vo.total_amount}</td>
                      <td>{$vo.day}</td>
                      <td>{$vo.created_at}</td>
                      <td class="index_status">
                        <if condition="$vo['status'] == 2">
                          <em class="payed">已打款</em>
                          <else />
                          <em class="unpayed">未打款</em>
                        </if>
                      </td>
                      <td>
                        <if condition="$vo['status'] == 2">
                          <else />
                          <a class="cm-edit" title="打款" onclick="change_status(this,{$vo.id},'{$vo.shop_name}',{$vo.status})"></a>
                        </if>
                      </td>
                    </tr>
                  </volist>
                </table>
              </div>

              <ul class="pagination pull-right">
                <li>
                  <a href="{$page_list.page.first.href}" aria-label="Previous">
                      <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <li>
                  <a href="{$page_list.page.front.href}" aria-label="Previous">
                      <span aria-hidden="true">&lt;</span>
                    </a>
                </li>
                <volist name="page_list.page.list" id="plist">
                  <li <eq name="plist.index" value="1">class="active"</eq>><a href="{$plist.href}">{$plist.page}</a></li>
                </volist>
                <li>
                  <a href="{$page_list.page.after.href}" aria-label="Next">
                      <span aria-hidden="true">&gt;</span>
                    </a>
                </li>
                <li>
                  <a href="{$page_list.page.last.href}" aria-label="Next">
                      <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="modal fade" id="order-detail">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title">订单详情</h4>
        </div>
        <div class="modal-body">
          <div class="product-item">
            <div class="product-item-hd">
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script>
    //改变状态
    function change_status(obj, id, name, status) {
      var url = "{:U('Settlements/change_status')}";
      var status_str;

      if (status != 3) {
        status = 2;
        status_str = "已打款";
      }

      if (confirm("确认是否" + status_str + '到' + name)) {
        $.post(url, {
          id: id,
          status: status
        }, function(data) {
          if (data.code != 'success') {
            alert(data.msg);
          } else {
            $(obj).parent().parent().find(".index_status").html(status_str);
            $(obj).hide();
          }
        });
      }
    }

    function show_spec(spec) {
      $('.product-item-hd').html(spec);
    }

    jeDate({
      dateCell: "#beg_time", //isinitVal:true,
      format: "YYYY-MM-DD",
      isinitVal: false,
      isTime: false,
      //isClear:false,
      minDate: "2014-09-19",
      okfun: function(val) {
        alert(val)
      }
    })

    jeDate({
      dateCell: "#end_time", //isinitVal:true,
      format: "YYYY-MM-DD",
      isinitVal: false,
      isTime: false, //isClear:false,
      minDate: "2014-09-19",
      okfun: function(val) {
        alert(val)
      }
    })
  </script>
</body>

</html>